class UserStocksController < ApplicationController
  layout "blank_scaffold"
  before_filter :login_required

  record_select :per_page => 10, :search_on => [:s_symbol, :detail], :order_by => 's_symbol ASC', :label => :detail

  active_scaffold :user_stock do |config|
    config.actions.exclude :delete
    config.list.per_page = 10
    config.columns = [:id, :s_symbol, :detail, :user_stock_trades]
    config.columns[:s_symbol].label = 'Symbol'
    config.columns[:user_stock_trades].label = 'Data'
    config.list.columns.exclude :user_stock_trades
    config.create.columns.exclude :id
    config.update.columns.exclude :id
    config.list.sorting = {:s_symbol => 'ASC'}

    config.action_links.add 'user_import_csv', :label => '<img src="/images/icon_csv.png" border="0" width="13px"/> Import From CSV', :page => true
  end

  def conditions_for_collection
    ['user_id=?', session[:user_id]]
  end

  def record_select_conditions_from_controller
    conditions = ["user_id=?", session[:user_id]]
  end
end
